import java.util.ArrayList;
import java.util.List;

public class Solution1380 {
    public List<Integer> luckyNumbers (int[][] matrix) {
        List<Integer> ans=new ArrayList<>();
        for (int i=0;i<matrix.length;i++){
            int min=Integer.MAX_VALUE;
            int pos=-1;
            for (int j=0;j<matrix[0].length;j++){
                if (matrix[i][j]<min){
                    min=matrix[i][j];
                    pos=j;
                }
            }
            boolean f=true;
            for (int j=0;j<matrix.length;j++){
                if (i!=j && matrix[j][pos]>matrix[i][pos]){
                    f=false;
                    break;
                }
            }
            if (f){
                ans.add(matrix[i][pos]);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1380().luckyNumbers(new int[][]{{3,7,8},{9,11,13},{15,16,17}}));
    }
}
